package com.hotel.api.service.impl;

import com.github.pagehelper.PageHelper;
import com.hotel.api.entity.AdminNotice;
import com.hotel.api.entity.UserRole;
import com.hotel.api.mapper.AdminNoticeMapper;
import com.hotel.api.mapper.UserRoleMapper;
import com.hotel.api.service.AdminService;
import com.hotel.api.entity.Lost;
import com.hotel.api.mapper.LostMapper;
import com.hotel.api.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * TODO
 *
 * @Author 涛涛
 * @Create 2019/8/29
 */
@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private LostMapper lostMapper;

    @Autowired
    private UserRoleMapper userRoleMapper;


    @Autowired
    private AdminNoticeMapper adminNoticeMapper;

    /**
     * 发布失物
     *
     * @param lost
     * @return
     */
    @Override
    public int addLost(Lost lost) {
        return lostMapper.insert(lost);
    }

    /**
     * 查看失物
     *
     * @return
     */
    @Override
    public List<Lost> selectAllLost() {
        return lostMapper.selectAllLost();
    }

    /**
     * 失物管理，修改失物状态，0为未认领，1为已认领
     *
     * @param lost
     * @return
     */
    @Override
    public int updateLost(Lost lost) {
        return lostMapper.updateLost(lost);
    }

    /**
     * 公告管理,发布公告
     *
     * @param adminNotice
     * @return
     */
    @Override
    public boolean addNotice(AdminNotice adminNotice) {
        int insert = adminNoticeMapper.insert(adminNotice);
        if (insert > 0) {
            return true;
        }
        return false;
    }

    /**
     * 公告管理，删除公告,del_state->0->1
     *
     * @param adminNotice
     * @return
     */
    @Override
    public int updateNotice(AdminNotice adminNotice) {
        return adminNoticeMapper.updateNotice(adminNotice);

    }

    @Override
    public UserRole adminLogin(Integer uid) {
        return userRoleMapper.adminLogin(uid) ;
    }

    /**
     * 公告管理，查看所有公告
     *
     * @return
     */
    @Override
    public List<AdminNotice> getNoticList() {
        return adminNoticeMapper.selectAll();
    }

    @Override
    public Lost findLostById(Integer id) {
        return lostMapper.findLostById(id);
    }


}
